﻿<UserControl 	
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 	
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 	
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 	
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" 	
    xmlns:local="clr-namespace:DiskUsage"  
    x:Class="DiskUsage.DirectoryListView" 	
    x:Name="UserControl" d:DesignWidth="100" d:DesignHeight="100">
    <UserControl.Resources>
        <local:FileSizeConverter x:Key="fileSizeConverter"/>
        <DataTemplate x:Key="HeaderTemplateArrowUp">
            <DockPanel>
                <TextBlock HorizontalAlignment="Center" Text="{Binding}"/>
                <Path x:Name="arrow"
                      StrokeThickness = "1"					  
                      Fill            = "gray"
                      Data            = "M 5,10 L 15,10 L 10,5 L 5,10"/>
            </DockPanel>
        </DataTemplate>
        <DataTemplate x:Key="HeaderTemplateArrowDown">
            <DockPanel>
                <TextBlock HorizontalAlignment="Center" Text="{Binding }"/>
                <Path x:Name="arrow"
                      StrokeThickness = "1"	
                      Fill            = "gray"
                      Data            = "M 5,5 L 10,10 L 15,5 L 5,5"/>
            </DockPanel>
        </DataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <ListView Name="m_listViewDetails"  MouseDoubleClick="m_listViewDetails_MouseDoubleClick" 
                  GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler">
            <ListView.ContextMenu>
                <ContextMenu StaysOpen="true">
                    <MenuItem Header="Calculate Size" Click="CalculateSize_Click"/>
                </ContextMenu>
            </ListView.ContextMenu>
            <ListView.Resources>
                <DataTemplate x:Key="IconTemplate">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="16" >
                            </ColumnDefinition>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" x:Name="img" Stretch="None" Source="{Binding Icon}"/>
                        <TextBlock Grid.Column="1" Text="{Binding Name}"/>
                    </Grid>
                </DataTemplate>
            </ListView.Resources>
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="200" Header="Name" CellTemplate="{StaticResource IconTemplate}" />
                    <GridViewColumn Width="150" Header="Date Modified" DisplayMemberBinding="{Binding DateModified}"/>
                    <GridViewColumn Width="100" Header="Type" DisplayMemberBinding="{Binding Type}" />
                    <GridViewColumn Width="100" Header="Size" DisplayMemberBinding="{Binding Size, 
                        Mode=OneWay, Converter={StaticResource fileSizeConverter}}" />
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</UserControl>